#include "../../h/apue.h"
#include "../utils.h"

int main(void)
{
    size_t pathlen;
    char * path = my_path_alloc(&pathlen);

    if (getcwd(path, pathlen) == NULL)
        err_sys("getcwd failed");
    else
        printf("getcwd: %s before chdir.\n", getcwd(path, pathlen));

    if (chdir("/var/lock") < 0)     /*/var/lock -> /run/lock*/
        err_sys("chdir failed");

    printf("chdir to /var/lock succeeded\n");
    if (getcwd(path, pathlen) == NULL)
        err_sys("getcwd failed");
    else
    printf("getcwd: %s after chdir.\n", getcwd(path, pathlen));

    return 0;
}
